<?php
    session_start();
    include("../models/webconfig.php");
    include("../models/class.connection.php");
    include("../models/entities/class.AccountEntity.php");
    include("../models/repositories/class.AccountRepository.php");
    include("../models/entities/class.CategoryEntity.php");
    include("../models/repositories/class.CategoryRepository.php");
    include("../models/entities/class.SectionEntity.php");
    include("../models/repositories/class.SectionRepository.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Liên h?</title>
<link rel="stylesheet" type="text/css" href="../content/front-end.css" />
<script type="text/javascript" src="../scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../scripts/search.js"></script>
<script type="text/javascript" src="../scripts/contact.js"></script>
<script type="text/javascript" src="../scripts/jquery.validate.js"></script>
</head>

<body>
	<div id="wrap">
		<?php
			include("../includes/frontend_Header.php");
            include("../includes/frontend_Left.php");
        ?>
        
        <div id="right">
        	<div class="box_content_t"></div>
            
        	<div class="box_content_m">
        		<!-- DEFINE YOUR CONTENT HERE -->
        		<form id="frmContact" method="post">
        			<div style="float:left; width:20%;font-weight:bold">Họ tên</div>
        			<div style="float:left; width:80%; text-align:left;"><input class="required" type="text" id="txtHoTen" name="HoTen" style="width:250px; font-size:12px; height:17px;"/></div><br/><br/>
        			<div style="float:left; width:20%;font-weight:bold">Địa chỉ</div>
        			<div style="float:left; width:80%; text-align:left;"><input type="text" name="DiaChi" id="txtDiaChi" style="width:250px; font-size:12px; height:17px;"/></div><br/><br/>
        			<div style="float:left; width:20%;font-weight:bold">Ðiện thoại</div>
        			<div style="float:left; width:80%; text-align:left;"><input type="text" name="DienThoai" id="txtDienThoai" style="width:250px; font-size:12px; height:17px;"/></div><br/><br/>
        			<div style="float:left; width:20%;font-weight:bold">Email</div>
        			<div style="float:left; width:80%; text-align:left;"><input class="required" type="text" id="txtEmail" name="Email" style="width:250px; font-size:12px; height:17px;"/></div><br/><br/>
        			<div style="float:left; width:20%;font-weight:bold">Nội dung</div>
        			<div style="float:left; width:80%; text-align:left;"><textarea class="required" id="txtNoiDung" name="NoiDung" style="width:250px; vertical-align:middle; font-size:12px;" rows="7"></textarea></div>
                    <div style="float:left; width:20%;font-weight:bold">&nbsp;</div>
        			<div style="float:left; width:80%; text-align:left;"><?php echo'<img src="../library/quickcaptcha/imagebuilder.php?rand=' . rand(0,999999) . '" border="1">'; ?></div>
        			<div style="float:left; width:20%;font-weight:bold">&nbsp;</div>
                    <div style="float:left; width:80%; text-align:left;"><input name="Captcha" type="text" id="txtCaptcha" style="width:135px; font-size:12px; height:17px;"/></div>
        			<div style="float:left; width:20%;font-weight:bold">&nbsp;</div>
        			<div style="float:left; width:80%; text-align:left; padding-top:5px;"><input type="submit" id="btnSend" value="Gửi" style="font-size:12px; height:25px; width:70px;" />&nbsp;&nbsp;
        			<input type="button" id="btnReset" value="Soạn lại" style="font-size:12px; height:25px; width:70px;"/></div>
                    <?php
                        if(isset($_POST['Captcha']))
                        {
                            if($_POST['Captcha'] == $_SESSION['string'])
                            {
                                if(isset($_POST['HoTen']) && isset($_POST['Email']) && isset($_POST['NoiDung']))
                                {
                                    $hoTen = $_POST['HoTen'];
                                    $diaChi = "";
                                    $dienThoai = "";
                                    $email = $_POST['Email'];
                                    $noiDung = $_POST['NoiDung'];
                                    if(isset($_POST['DiaChi']))
                                    {
                                        $diaChi = $_POST['DiaChi'];
                                    }
                                    if(isset($_POST['DienThoai']))
                                    {
                                        $dienThoai = $_POST['DienThoai']; 
                                    }
                                    require_once("../library/phpmailer/class.phpmailer.php");
                                    $mail = new PHPMailer();
                        			$mail->IsSMTP();
                        			$mail->SMTPAuth = true;
                                    $mail->SMTPSecure = 'ssl';
                        			$mail->Username = "cactusdlu@gmail.com";
                        			$mail->Password = "it.dlu.edu.vn";
                        			
                        			
                        			$mail->From = $email;
                        			$mail->FromName = $hoTen;
                        			$mail->AddAddress("eronfin@gmail.com", "Eron");
                        			$mail->AddReplyTo($email, $hoTen);
                        			$mail->WordWrap = 50;
                        			$mail->IsHTML(true);
                        			$mail->Subject = "Liên hệ";
                                    $body = "Họ tên: " . $hoTen . "<br/>Ðịa chỉ: " . $diaChi . "<br/>Email: " . $email . "<br/>Nội dung: " . $noiDung;
                        			$mail->Body = $body;
                        			if(!$mail->Send())
                        			{
                        				echo "Mailer Error: " . $mail->ErrorInfo;
                        			}
                        			else
                        			{?>
                                    <div style="float:left; width:20%;font-weight:bold">&nbsp;</div>
                                    <div style="float:left; width:80%; text-align:left; padding-top:5px;">Thu dã du?c g?i</div>
                        			<?php
                                    }
                                }
                            }
                            else
                            {?>
                                <div style="float:left; width:20%;font-weight:bold">&nbsp;</div>
                                <div style="float:left; width:80%; text-align:left; padding-top:5px;">Nhập chuỗi kiểm tra không chính xác</div>
                    			<?php
                            }
                        }
                    ?>
        		</form>
        		<!-- END DEFINE YOUR CONTENT HERE -->
        	</div>
            <div class="box_content_b"></div>
        </div>
	</div>
	<?php
		include("../includes/frontend_footer.php");
	?>
    
</body>

</html>
